import Vue from 'vue'
import App from './App'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
import store from './store'
import Vuex from 'vuex'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css'// progress bar style
import {initMenu} from './utils/utils'

import router from './routes'
// import Mock from './mock'
// Mock.bootstrap();
import 'font-awesome/css/font-awesome.min.css'

Vue.use(ElementUI)
Vue.use(Vuex)

import VueQuillEditor  from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor);


NProgress.configure({ showSpinner: false });

router.beforeEach((to, from, next) => {
  NProgress.start();
  if (to.path == '/login') {
    sessionStorage.removeItem('user');
  }
  let user = JSON.parse(sessionStorage.getItem('user'));
  console.log(user)
  if (!user && to.path != '/login') {
    next({ path: '/login' })
  } else {
    if(to.path != '/login'){
      initMenu(router,store)
    }
    next()
  }
})

router.afterEach(transition => {
  NProgress.done();
});


// Vue.prototype.imageService = 'https://files.oyilan.top/yika'
Vue.prototype.imageService = 'https://files.oyilan.top/aylan'
// Vue.prototype.imageService = 'http://192.168.199.150:8181'

new Vue({
  //el: '#app',
  //template: '<App/>',
  router,
  store,
  //components: { App }
  render: h => h(App)
}).$mount('#app')

